import React from 'react'
import orders from '../../../assets/css/user/orders/orders.module.css'

export default class EvaluatedIndex extends React.Component {
    constructor(){
        super();
        this.state={
            list:[]
        }
    }
    componentWillMount() {
        this.getData();
    }
    getData(){
        let uid=localStorage.uid;
        fetch("http://vueshop.glbuys.com/api/user/myorder/reviewOrder?uid="+uid+"&page=1&token=1ec949a15fb709370f")
            .then(res=>{
                return res.json()
            }).then(res=>{
            if(res.code===200){
                this.setState({list:res.data});
            }
        })
    }

    render() {
        return(
            <div>
                <ul className={orders.boxOrders}>
                    {this.state.list.map((item,index)=>{
                        return(
                            item.goods!==null?
                            <li key={index}>
                                <div className={orders.boxDiv}>
                                    <p>订单编号：<span>{item.ordernum}</span></p>
                                    <p>已收货</p>
                                </div>
                                {item.goods.map((Item,Index)=>{
                                    return(
                                        <div key={Index} className={orders.boxDivOne}>
                                            <img src={Item.image} alt=''/>
                                            <div>
                                                <p>{Item.title}</p>
                                                <span>x{Item.amount}</span>
                                            </div>
                                        </div>
                                    )
                                })}
                                <div className={orders.boxFoot}>
                                    <p>支付金额：<span>￥{item.total}</span></p>
                                    <p>
                                        <span>评价</span >
                                    </p>
                                </div>
                            </li>:''
                        )
                    })}
                </ul>
            </div>
        )
    }
}